package com.theima.socket.socketdemo6;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @program: Myset
 * @description:
 * @author: xuejingjing
 * @create: 2021-06-26 13:31
 **/
public class SeverDemo {
    public static void main(String[] args) throws IOException {
         //1.创建Socket对象
        ServerSocket ss = new ServerSocket(10000);
        //2.等待客户端连接；有客户连接了，就返回Socket对象，没有客户连接了，就一直死等（这个状态叫做阻塞）。
        Socket accept = ss.accept();
        //3.获得输入流对象
        InputStream is = accept.getInputStream();
        int b;
        while((b = is.read())!= -1){
            System.out.print((char)b);
        }

        //4.释放资源
        is.close();



    }
}
